fix(bitbucket): Bitbucket Cloud pagination not working beyond first page#502
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@bardock I tested and found the following error: [dev:backend ] 2025-09-10T18:08:08.875Z error: [bitbucket] Failed to get repos for workspace facebot: TypeError: Invalid URL Apparently, the baseUrl is not being used, and when adjusting it, the issue of duplicating /2.0 occurs. |
brendan-kellam
left a comment
There was a problem hiding this comment.
Thanks for your contribution!! Overall LGTM - let's make sure it's working for @WendelBartzUbots, and afterwards will be g2g to merge.
Fix: Bitbucket Cloud pagination not working beyond first page
Problem
Issue: #295
When fetching repositories from Bitbucket Cloud workspaces with multiple pages of results, Sourcebot fails on the second page with the following error:
This is caused by the Bitbucket Cloud API returning full URLs (e.g.,
https://api.bitbucket.org/2.0/repositories/workspace?page=2) in paginationnextresponses, butopenapi-fetchexpects separate path and query parameters. The current implementation was passing the full URL directly to the API client, which doesn't recognize the complete URL format.Solution
This PR implements proper URL parsing for Bitbucket Cloud pagination to separate paths and query parameters. The implementation includes:
1. URL Parsing Function
parseUrl()function that properly extracts pathname and query parameters from full URLsURLconstructor for robust and performant parsing2. Updated Pagination Handlers
cloudGetReposForWorkspace()to use parsed URL componentscloudGetReposForProjects()to use parsed URL componentspathandqueryparameters separately toopenapi-fetchTesting
Breaking Changes
None. The changes are backward compatible and only affect the internal pagination URL handling.
Notes